package cn.lastjune.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.lastjune.dao.EmployeeDao;
import cn.lastjune.pojo.Employee;
import cn.lastjune.service.EmployeeService;
import cn.lastjune.util.Page;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService
{

    @Autowired
    EmployeeDao dao;

    @Override
    public Page<Employee> getAllEmployee(final Page<Employee> page)
    {
        return dao.getPageAll(page);
    }

    @Override
    public void insertEmployee(final Employee Employee)
    {
        dao.add(Employee);
    }

    @Override
    public void deleteEmployee(final String id)
    {
        dao.delete(id);
    }

    @Override
    public void updateEmployee(final Employee employee)
    {
        final Employee original = dao.get(employee.getEmployeeid());
        original.setEmployeename(employee.getEmployeename());
        original.setContact(employee.getContact());
        original.setPassword("123");
        dao.update(original);
    }

    @Override
    public Employee getEmployeeById(String id)
    {
        return dao.getEmployeeByID(id);
    }

	@Override
	public List<Employee> getallEmployee() {
		return dao.getAll();
	}

	@Override
	public List<Employee> getByName(String name) {
		 return dao.getByName(name);
	}

}
